import Vue from 'vue';
var mpheader = require("../components/mpheader.js");

var applyContractvue, theIScroll;

// 创建普通提示框
function createapplyContractvue(commonData,cfunc,contranctInfo) {
    $("#wrapper").css("height", window.innerHeight - 44 + "px");
//    $("#wrapper").on("touchmove", showUpimge);
    theIScroll = new IScroll("#wrapper");
    setUpImgPosition();
    var mheder1 = mpheader.getMPheader({
        "titleText": "申请小通秒贷"
    }, cfunc);
    applyContractvue = new Vue({
        el: "#apply_contract",
        data: {
            commonData: commonData,
            info:contranctInfo
        },
        components: {
            "mpheader": mheder1
        },
        methods: {
            "showUpimge": function() {
                var wstop = $("#wrapper")[0].scrollTop;
                if (wstop < 30) {
                    $("#upImg").css("display","none");
                } else {
                    $("#upImg").css({"display":"block","position":"fixed"});
                }
            },
            "toTop": function() {
                $("#wrapper")[0].scrollTop = 0;
                $("#upImg").css("display","none");
            }
        }
    });

    return applyContractvue;
}


/* 设置回到头部图标位置 */
function setUpImgPosition() {
    var ptop = (parseInt($("#wrapper").css("height")) - 40) + "px";
    $("#upImg").css({
        "top": ptop,
        "right": "15px"
    });
}

function showUpimge() {
    if (theIScroll.y > -30) {
        $("#upImg").hide();
    } else {
        $("#upImg").show();
    }
}

module.exports = {
    createapplyContractvue: createapplyContractvue
}